# coding=utf-8
import sys
import commands
import os
from django import forms
from django.core.paginator import Paginator, InvalidPage, EmptyPage, PageNotAnInteger
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.http.response import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.template import RequestContext
# from interface.app.parameters.ia_configure import user,uid,name
from blued_tools.tools import *
from blued_tools.loading import myloader
from blued_tools.mvs import search_movice
from cryptograph import prpcrypt_ios, prpcrypt_android, Keeper
from models import *
from qaweb.settings import ONE_PAGE_OF_DATA, dropdown, bg
from interface.main import main
from IM.message_box import client
from collections import OrderedDict
import json
import time
import myinter
import os

sys.path.append('master/manage')


class Userform(forms.Form):
    username = forms.CharField(label='', max_length=20,
                               widget=forms.TextInput(attrs={"style": "width:285px;", 'placeholder': '用户名/email'}))
    password = forms.CharField(label='', max_length=30,
                               widget=forms.PasswordInput(attrs={"style": "width:285px;", 'placeholder': 'password'}))
    repassword = forms.CharField(label='', max_length=30, widget=forms.PasswordInput(
        attrs={"style": "width:285px;", 'placeholder': 'repassword'}))
    # email = forms.EmailField()
    phone = forms.IntegerField(label='',
                               widget=forms.TextInput(attrs={"style": "width:285px;", 'placeholder': 'Phone'}))

    sex = forms.ChoiceField(label='', choices=[('男', '男'), ('女', '女')], widget=forms.RadioSelect())


class Loginform(forms.Form):
    username = forms.CharField(label='', max_length=20, widget=forms.TextInput(
        attrs={"style": "width:285px;", 'placeholder': '用户名/email', 'id': 'username'}))
    password = forms.CharField(label='', max_length=30, widget=forms.PasswordInput(
        attrs={"style": "width:285px;", 'placeholder': 'password', 'id': 'password'}))


def index(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    return render(req, 'moban1788/index.html')


def login(req):
    if req.method == 'POST':
        lform = Loginform(req.POST)
        if lform.is_valid():
            username = lform.cleaned_data['username']
            password = lform.cleaned_data['password']
            users = register.objects.filter(username__exact=username, password__exact=password)
            if users:
                req.session['username'] = username
                return HttpResponseRedirect('../index/')
            else:
                response = HttpResponse()
                response.write("<script>alert('用户名密码错误');window.location.href='../login'</script>")
                return response
    else:
        lform = Loginform()
    return render(req, 'login.html', {'lform': lform})


def onregister(req):
    if req.method == 'POST':
        form = Userform(req.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            repassword = form.cleaned_data['repassword']
            sex = form.cleaned_data['sex']
            phone = form.cleaned_data['phone']
            reg = register()
            reg.username = username
            reg.password = password
            reg.repassword = repassword
            reg.sex = sex
            reg.phone = phone
            reg.save()
            req.session['username'] = username
            return HttpResponseRedirect('../index/')
    else:
        form = Userform()
    return render(req, 'register.html', {'form': form})


def logout(req):
    del req.session["username"]
    return HttpResponseRedirect('../index/')


def chart(req):
    uid = req.GET.get('uid', '')
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    return render(req, 'charts.html', {'username': username, 'username1': username1})


def table(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    row1 = register.objects.all()
    # 分页
    paginator = Paginator(row1, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        articlelist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        articlelist = paginator.page(page.num_pages)
    return render(req, 'tables.html', locals())


def ondownload(req):
    downlist = download.objects.all()

    paginator = Paginator(downlist, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        articlelist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        articlelist = paginator.page(page.num_pages)
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    return render(req, '../templates/moban1788/tools/download.html', locals())


def delete(req, id):
    dele = get_object_or_404(register, pk=int(id))
    dele.delete()
    return HttpResponseRedirect(reverse("blued_list"))


def crypoto(req):
    username = req.session.get('username')
    encry_android = req.GET.get('encry_android', '')  # 加密Android
    decry_android = req.GET.get('decry_android', '')  # 解密Android
    encryp_ios = req.GET.get('encryp_ios', '')  # 加密ios
    decry_ios = req.GET.get('decry_ios', '')  # 解密ios
    crypt_a = prpcrypt_android()
    crypt_i = prpcrypt_ios()
    just_vowels = Keeper('"_: ')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    if encry_android:
        try:
            state = 1
            result = crypt_a.padAK(crypt_a.encrypt(encry_android))
        except:
            state = 2
            result = "不~~,呜呜呜,老天爷太不公平了,不就输了不合法字符嘛,要不要这样对待我 !!!"
    elif decry_android:
        try:
            decry_android = str(decry_android)
            decry_android = just_vowels(u'%s' % decry_android)
            decry_android = str(decry_android)
            decry_android = unicode(decry_android, 'unicode-escape')
            result = crypt_a.decrypt(crypt_a.unak(decry_android))
            if result == '':
                state = 0
                result = '啊~~,怎么会这样,一点是哪里点错了,赶紧查查 !!!'
            else:
                state = 1
        except:
            state = 2
            result = "不~~,怎么就解密不出来呢,一定是输入哪里不对,嗯,肯定是 !!!"
    elif encryp_ios:
        try:
            state = 1
            result = crypt_i.padAK(crypt_i.encrypt(encryp_ios))
        except:
            state = 2
            result = "不~~,呜呜呜,老天爷太不公平了,不就输了不合法字符嘛,要不要这样对待我 !!!"
    elif decry_ios:
        try:
            decry_ios = str(decry_ios)
            decry_ios = just_vowels(u'%s' % decry_ios)
            result = crypt_i.decrypt(crypt_i.unak(decry_ios))
            if result == '':
                state = 0
                result = '啊~~,怎么会这样,一点是哪里点错了,赶紧查查 !!!'
            else:
                state = 1
        except:
            state = 2
            result = "不~~,怎么就解密不出来呢,一定是输入哪里不对,嗯,肯定是 !!!"
    else:
        state = 1
        result = ""
    content = {
        'username': username,
        'username1': username1,
        'result': result,
        'state': state,
        'dropdown_tt': dropdown,
        'bg_crypoto': bg,
    }
    # if username == None:
    #     return login(req)
    # else:
    return render(req, '../templates/moban1788/tools/crypto.html', content)


def anchor_tools(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    uid = req.GET.get('uid', '')
    url = req.GET.get('url', '')
    users = req.GET.get('users', '')
    passwds = req.GET.get('passwds', '')
    is_online = req.GET.get('is_online', '')
    uid = str(uid)
    url = str(url)
    if uid != '':
        uid = "http://a.blued.cn/blacklist.php?UID=" + uid
        active = 'active'
        active1 = ''
        active2 = ''
        res_url = ''
    elif url != '':
        active = ''
        active1 = ''
        active2 = 'active'
        interface = myinter.splash(url, users, passwds, is_online)
        res_url = interface.post()
    else:
        active1 = 'active'
        active2 = ''
        active = ''
        res_url = ''
    content = {
        'active': active,
        'active1': active1,
        'active2': active2,
        'res_url': res_url,
        'uid': uid,
        'username': username,
        'username1': username1,
        'dropdown_tt': dropdown,
        'bg_anchor_tools': bg,
    }
    # if username == None:
    #     return login(req)
    # else:
    return render(req, '../templates/test_tools/anchor_tools.html', content)


def myblog(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    content = {
        'username': username,
        'username1': username1
    }
    return render(req, 'myblog.html', content)


def parameters(req):
    username = req.session.get('username')
    uid = req.GET.get('uid', '')
    select = req.GET.get('select', '')
    sums = req.GET.get('sums', '')
    en = req.GET.get('en', '')
    select_en = req.GET.get('select_en', '')
    identity_get = req.GET.get('identity', '')
    button = req.GET.get('search_identity', '')
    star_uid = req.GET.get('star_uid', '')
    sel_vbadge = req.GET.get('sel_vbadge', '')
    payment = req.GET.get('payment', '')
    safe_uid = req.GET.get('safe_uid', '')
    safe_button = req.GET.get('safe_email', '')
    safe_select = req.GET.get('select_safe', '')
    margin_left = 50
    if 'Chrome' not in req.META['HTTP_USER_AGENT']:
        margin_left = 70
    safe_uid_result = ''
    if payment != '':
        result_payment = change_payment(payment, 0)
        if result_payment[0] == 1 and result_payment[1] == 0 and result_payment[2] == 0:
            response = HttpResponse()
            response.write("<script>alert('修改成功');window.location.href='../parameters'</script>")
            return response
        else:
            response = HttpResponse()
            response.write(
                "<script>alert('修改失败,原密码可能是与要修改的密码相同或者没有创建过密码');window.location.href='../parameters'</script>")
            return response
    try:
        identity_get = str(identity_get)
    except:
        response = HttpResponse()
        response.write("<script>alert('对不起,请输入合法字符');window.location.href='../parameters'</script>")
        return response
    if en != '':
        try:
            chaxun = chaxu_uid(select_en, en)
            state = chaxun[1]
        except:
            state = 0
        if state == 1:
            result_uid = chaxun[0][0]
            result_beans = chaxun[2][0]
            result_level = chaxun[2][1]
            result_avatar = chaxun[2][2]
            result_name = chaxun[2][3]
            result_reg_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(chaxun[2][4])))
        else:
            response = HttpResponse()
            response.write("<script>alert('对不起,没有查询到该uid');window.location.href='../parameters'</script>")
            return response
    else:
        result_uid = ''
        result_beans = ''
        result_level = ''
        result_avatar = ''
        result_name = ''
        result_reg_date = ''
    if uid != '' and sums != '':
        try:
            uid = int(uid)
            sums = int(sums)
            state = change_wandou(sums, uid, select)
        except:
            state = 0
        if state == 1:
            response = HttpResponse()
            response.write("<script>alert('修改成功');window.location.href='../parameters'</script>")
            return response
        else:
            response = HttpResponse()
            response.write("<script language='javascript'>alert('修改失败');window.location.href='../parameters'</script>")
            return response
    if button:
        authcode = yanzhengma(identity_get)
        if authcode == None:
            authcode = "没有查询到验证码哟 !!"
            chaxun_yanzhengma()
            identitylist = identity.objects.all()
        else:
            identitylist = ''
    else:
        authcode = ''
        identitylist = ''

    if safe_button:
        safe_select = int(safe_select)
        safe_uid = str(safe_uid)
        safe_uid_result = safeEmail(safe_uid, safe_select)
        if safe_uid_result == '':
            safe_uid_result = "查无结果"
    print safe_uid_result
    # 明星号
    if star_uid != '':
        try:
            res = change_star(star_uid, sel_vbadge)
        except:
            response = HttpResponse()
            response.write("<script>alert('字符不合法,请输入合法字符');window.location.href='../parameters'</script>")
            return response
        if res == 0:
            response = HttpResponse()
            response.write("<script>alert('修改成功');window.location.href='../parameters'</script>")
            return response
        else:
            response = HttpResponse()
            response.write("<script>alert('修改失败,请检查uid是否正确');window.location.href='../parameters'</script>")
            return response
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    content = {
        'username': username,
        'username1': username1,
        'result_uid': result_uid,
        'result_beans': result_beans,
        'result_level': result_level,
        'result_avatar': result_avatar,
        'result_name': result_name,
        'result_reg_date': result_reg_date,
        'authcode': authcode,
        'identity': identitylist,
        'dropdown_tt': dropdown,
        'bg_parameters': bg,
        'safe_uid_result': safe_uid_result,
        'margin_left': margin_left
    }
    # if username == None:
    #     return login(req)
    # else:
    return render(req, '../templates/moban1788/tools/tools.html', content,
                  )


def parameters_i(req):
    username = req.session.get('username')
    i_uid = req.GET.get('i_uid', '')
    i_select = req.GET.get('i_select', '')
    i_sums = req.GET.get('i_sums', '')
    payment = req.GET.get('payment', '')
    ipt_yzm = req.GET.get('ipt_yzm', '')
    en = req.GET.get('en', '')
    select_en = req.GET.get('select_en', '')
    # del_yzm = req.GET.get('del_yzm', '')
    if en != '':
        try:
            chaxun = chaxu_uid(select_en, en)
            state = chaxun[1]
        except:
            state = 0
        if state == 1:
            result_uid = chaxun[0][0]
            result_beans = chaxun[2][0]
            result_level = chaxun[2][1]
            result_avatar = chaxun[2][2]
            result_name = chaxun[2][3]
            result_reg_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(chaxun[2][4])))
        else:
            response = HttpResponse()
            response.write("<script>alert('对不起,没有查询到该uid');window.location.href='../parameters'</script>")
            return response
    else:
        result_uid = ''
        result_beans = ''
        result_level = ''
        result_avatar = ''
        result_name = ''
        result_reg_date = ''
    if payment != '':
        result_payment = change_payment(payment, 1)
        if result_payment[0] == 1 and result_payment[1] == 0 and result_payment[2] == 0:
            response = HttpResponse()
            response.write("<script>alert('修改成功');window.location.href='../parameters_i'</script>")
            return response
        else:
            response = HttpResponse()
            response.write(
                "<script>alert('修改失败,原密码可能是与要修改的密码相同或者没有创建过密码');window.location.href='../parameters_i'</script>")
            return response
    if i_uid != '' and i_sums != '':
        try:
            i_uid = int(i_uid)
            i_sums = int(i_sums)
            i_state = i_change_wandou(i_sums, i_uid, i_select)
        except:
            i_state = 0
        if i_state == 1:
            response = HttpResponse()
            response.write("<script>alert('修改成功');window.location.href='../parameters_i'</script>")
            return response
        else:
            response = HttpResponse()
            response.write(
                "<script language='javascript'>alert('修改失败');window.location.href='../parameters_i'</script>")
            return response
    if ipt_yzm != '':
        resDel = delYzm(ipt_yzm)
        if resDel == 1:
            response = HttpResponse()
            response.write(
                "<script language='javascript'>alert('清空验证码成功');window.location.href='../parameters_i'</script>")
            return response
        else:
            response = HttpResponse()
            response.write(
                "<script language='javascript'>alert('清空验证码失败,手机号不正确或者该手机号已经被清空');window.location.href='../parameters_i'</script>")
            return response
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    content = {
        'username': username,
        'username1': username1,
        'result_uid': result_uid,
        'result_beans': result_beans,
        'result_level': result_level,
        'result_avatar': result_avatar,
        'result_name': result_name,
        'result_reg_date': result_reg_date,
        'dropdown_tt': dropdown,
        'bg_parameters': bg,
    }
    # if username == None:
    #     return login(req)
    # else:
    return render(req, '../templates/moban1788/tools/tools_inter.html', content,
                  )


def autocli(req):
    username = req.session.get('username')
    clean_data = req.GET.get('clean_data', '')
    platform = req.GET.get('platform', '')
    result = req.GET.get('result', '')
    version = req.GET.get('version', '')
    submit = req.GET.get('submit', '')
    url = req.get_raw_uri().split('/')[-1]
    # url = req.get_raw_uri().split('/')[-1].split('page=')[0]
    if url != "":
        if url[0:6] == "?page=":
            url = url.split('?page=')[0] + '?'
        else:
            url = url.split('&page=')[0] + '&'
    else:
        url = url + '?'
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    if submit:
        if int(platform) != 0 or int(result) != 6 or str(version) != '':
            platform = int(platform)
            result = int(result)
            version = str(version)
            if platform == 1:
                platform = "android"
            elif platform == 2:
                platform = "ios"
            if platform != 0 and result == 6 and version == '':
                atclient = interface_aotoclient.objects.filter(platform=platform)
            elif platform == 0 and result != 6 and version == '':
                atclient = interface_aotoclient.objects.filter(result=result)
            elif platform == 0 and result == 6 and version != '':
                atclient = interface_aotoclient.objects.filter(version=version)
            elif platform != 0 and result != 6 and version == '':
                atclient = interface_aotoclient.objects.filter(platform=platform, result=result)
            elif platform == 0 and result != 6 and version != '':
                atclient = interface_aotoclient.objects.filter(result=result, version=version)
            elif platform != 0 and result == 6 and version != '':
                atclient = interface_aotoclient.objects.filter(platform=platform, version=version)
            elif platform != 0 and result != 6 and version != '':
                atclient = interface_aotoclient.objects.filter(platform=platform, result=result, version=version)
        else:
            atclient = interface_aotoclient.objects.all()
    else:
        atclient = interface_aotoclient.objects.all()
    # 清除数据
    if clean_data:
        interface_aotoclient.objects.filter().delete()
        os.system("rm qa/static/images/client/*")
    # 分页
    paginator = Paginator(atclient, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        atclientlist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        atclientlist = paginator.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'atclient': atclient,
        'paginator': paginator,
        'atclientlist': atclientlist,
        'bg_autocli': bg,
        'dropdown_tb': dropdown,
        'url': url,
    }
    return render(req, '../templates/moban1788/autolog/UI_auto_log.html', content,
                  )


def autoser(req):
    username = req.session.get('username')
    run_states = req.GET.get('run_states', '')
    s = commands.getoutput("ps aux | grep main.py")
    stat = s.split()
    if stat[10] + stat[11] == "pythonmain.py":
        run_time = stat[9]
        pid = stat[1]
        run_state = 1
        state = 'Stop'
    else:
        run_time = 0
        run_state = 0
        state = 'Run'
    if run_states == 'Stop':
        try:
            os.system('kill %s' % pid)
            state = "Run"
            run_time = 0
        except:
            response = HttpResponse()
            response.write("<script>alert('脚本已停止,请刷新页面');window.location.href='../autoser'</script>")
            return response
    if run_states == 'Run':
        try:
            s_second = commands.getoutput("ps aux | grep manage.py")
            stat2 = s_second.split()
            if stat2[10] + stat2[11] == "pythonmanage.py":
                response = HttpResponse()
                response.write("<script>alert('脚本正在启动中,请刷新页面');window.location.href='../autoser'</script>")
                return response
            else:
                path = os.getcwd()
                os.chdir('/home/work/Interface_auto_all/')
                os.system("nohup python main.py &")
                os.chdir(path)
                state = "Stop"
                run_time = "00:00"
        except:
            response = HttpResponse()
            response.write("<script>alert('脚本正在启动中,请刷新页面');window.location.href='../autoser'</script>")
            return response
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    atserver = interface_aotoserver.objects.all()
    # 分页
    paginator = Paginator(atserver, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        atserverlist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        atserverlist = paginator.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'atserver': atserver,
        'paginator': paginator,
        'atserverlist': atserverlist,
        'bg_autoser': bg,
        'dropdown_tb': dropdown,
        'run_state': run_state,
        'run_time': run_time,
        'state': state
    }
    return render(req, '../templates/moban1788/autolog/server_log_online.html', content,
                  )


def release(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    trelease = release_table.objects.all()
    # 分页
    paginator = Paginator(trelease, ONE_PAGE_OF_DATA - 5)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        treleaselist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        treleaselist = paginator.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'trelease': trelease,
        'paginator': paginator,
        'treleaselist': treleaselist,
    }
    return render(req, '../templates/moban1788/releasetable/release_table.html', content,
                  )


def irelease(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    irelease = release_itable.objects.all()
    # 分页
    paginator_i = Paginator(irelease, ONE_PAGE_OF_DATA - 5)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        ireleaselist = paginator_i.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        ireleaselist = paginator_i.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'irelease': irelease,
        'ireleaselist': ireleaselist,
        'paginator_i': paginator_i,
    }
    return render(req, '../templates/moban1788/releasetable/irelease_table.html', content,
                  )


def ua(req):
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    user_agent = interface_useragent.objects.all()
    # 分页
    paginator = Paginator(user_agent, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        user_agent_list = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        user_agent_list = paginator.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'user_agent': user_agent,
        'user_agent_list': user_agent_list,
        'paginator': paginator,
        'dropdown_tb': dropdown,
        'bg_ua': bg,
    }
    return render(req, '../templates/moban1788/autolog/useragent.html', content)


def colua(req):
    user_agent = interface_useragent.objects.all()
    # 分页
    paginator = Paginator(user_agent, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        user_agent_list = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        user_agent_list = paginator.page(page.num_pages)
    content = {
        'user_agent': user_agent,
        'user_agent_list': user_agent_list,
        'paginator': paginator,
    }
    return render(req, '../templates/activity/user_agent.html', content)


def ua_phone(req):
    return render(req, '../templates/activity/useragen.html')


def myjson(req):
    return render(req, '../templates/test_tools/myjson.html', {'myjson': bg, 'dropdown_tt': dropdown,})


def select_at():
    query_at = auto_time_debug.objects.filter(id=1).values()[0]
    return query_at
    # query_online = query_at['is_online']
    # query_username = query_at['usernames']
    # query_password = query_at['passwords']
    # query_uid = query_at['uid']
    # query_nickname = query_at['nickname']


def autoser_test(req):
    username = req.session.get('username')
    clean_data = req.GET.get('clean_data', '')
    checkbox_groups = req.GET.get('groups', '')
    checkbox_users = req.GET.get('users', '')
    checkbox_ticktocks = req.GET.get('ticktocks', '')
    checkbox_blued = req.GET.get('blued', '')
    checkbox_h5 = req.GET.get('h5', '')
    checkbox_pay = req.GET.get('pay', '')
    checkbox_passport = req.GET.get('passport', '')
    btn_select = req.GET.get('btn_select', '')
    is_online = req.GET.get('is_online', '')
    u_username = req.GET.get('u_username', '')
    u_password = req.GET.get('u_password', '')
    u_uid = req.GET.get('u_uid', '')
    u_nickname = req.GET.get('u_nickname', '')
    change_data = req.GET.get('change_data', '')
    u_host = req.GET.get('u_host', '')
    table_style = 'block'
    config_style = 'none'
    uid_style = 'inline'
    result_json = ''
    if btn_select:
        table_style = 'none'
        config_style = 'block'
    # 修改运行配置
    if change_data:
        if u_host == '':
            auto_time_debug.objects.filter(id=1).update(is_online=is_online, usernames=u_username, passwords=u_password,
                                                        uid=u_uid, nickname=u_nickname)
        else:
            auto_time_debug.objects.filter(id=1).update(host=u_host, is_online=is_online, usernames=u_username,
                                                        passwords=u_password, uid=u_uid, nickname=u_nickname)
    query_at = select_at()
    query_online = query_at['is_online']
    query_username = query_at['usernames']
    # query_password = query_at['passwords']
    query_uid = query_at['uid']
    query_nickname = query_at['nickname']
    if query_online == 0:
        environment = '测试环境'
    elif query_online == 1:
        environment = '线上环境'
    else:
        environment = auto_time_debug.objects.get(id=1).host
        uid_style = 'none'
    if checkbox_groups == 'groups':
        res_groups = 1
    else:
        res_groups = 0
    if checkbox_users == 'users':
        res_users = 1
    else:
        res_users = 0
    if checkbox_ticktocks == 'ticktocks':
        res_ticktocks = 1
    else:
        res_ticktocks = 0
    if checkbox_blued == 'blued':
        res_blued = 1
    else:
        res_blued = 0
    if checkbox_h5 == 'h5':
        res_h5 = 1
    else:
        res_h5 = 0
    if checkbox_pay == 'pay':
        res_pay = 1
    else:
        res_pay = 0
    if checkbox_passport == 'passport':
        res_psp = 1
    else:
        res_psp = 0
    if res_pay != 0 or res_users != 0 or res_blued != 0 or res_groups != 0 or res_h5 != 0 or res_ticktocks != 0 or res_psp != 0:
        jianquan_main = main(res_users, res_groups, res_blued, res_ticktocks, res_h5, res_pay, 0, res_psp)
        try:
            if jianquan_main[0] == 0:
                if jianquan_main[1] == 4036002:
                    response = HttpResponse()
                    response.write("<script>alert('验证码输入错误');window.location.href='../autoser_test'</script>")
                    return response
                    # print '验证码输入错误'
                elif jianquan_main[1] == 401:
                    response = HttpResponse()
                    response.write("<script>alert('用户名密码不正确');window.location.href='../autoser_test'</script>")
                    return response
                    # print '用户名密码不正确'
                else:
                    response = HttpResponse()
                    response.write(
                        "<script>alert('登录失败,错误码%s');window.location.href='../autoser_test'</script>" % jianquan_main[
                            1])
                    return response
                    # print '登录失败,错误码%s'%jianquan[0]
        except:
            pass
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    atserver = interface_aotoserver_debug.objects.all()
    # 清除数据
    if clean_data:
        interface_aotoserver_debug.objects.filter().delete()
    none_data = len(atserver.values())
    # 分页
    paginator = Paginator(atserver, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        atserverlist = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        atserverlist = paginator.page(page.num_pages)
    content = {
        'username': username,
        'username1': username1,
        'atserver': atserver,
        'paginator': paginator,
        'atserverlist': atserverlist,
        'bg_autoser_test': bg,
        'dropdown_tb': dropdown,
        'table_style': table_style,
        'result_json': result_json,
        'config_style': config_style,
        'environment': environment,
        'query_username': query_username,
        'query_uid': query_uid,
        'query_nickname': query_nickname,
        'uid_style': uid_style,
        'none_data': none_data,
        'query_online': query_online
    }
    # return render(req, '../templates/moban1788/autolog/server_log_test.html', content,
    #                           )
    return render(req, '../templates/moban1788/autolog/moble_interface.html', content,
                  )


def detail(req):
    data_id = req.GET.get('id', '')
    data_id = int(data_id)
    query_at = select_at()
    query_username = query_at['usernames']
    query_uid = query_at['uid']
    query_nickname = query_at['nickname']
    if data_id == '':
        response = HttpResponse()
        response.write("<script>alert('请求id为空');window.location.href='../'</script>")
        return response
    try:
        data = interface_aotoserver_debug.objects.filter(id=data_id)
    except:
        response = HttpResponse()
        response.write("<script>alert('未找到该条记录');window.location.href='../'</script>")
        return response
    content = {
        'data': data,
        'bg_autoser_test': bg,
        'dropdown_tb': dropdown,
        'user': query_username,
        'uid': query_uid,
        'name': query_nickname
    }
    return render(req, '../templates/moban1788/tools/detail_server.html', content,
                  )


def detail_client(req):
    data_id = req.GET.get('id', '')
    data_id = int(data_id)
    query_at = select_at()
    query_username = query_at['usernames']
    query_uid = query_at['uid']
    query_nickname = query_at['nickname']
    if data_id == '':
        response = HttpResponse()
        response.write("<script>alert('请求id为空');window.location.href='../autocli'</script>")
        return response
    try:
        data = interface_aotoclient.objects.filter(id=data_id)
        images = str(data.values()[0]['screenshot'])
    except:
        response = HttpResponse()
        response.write("<script>alert('未找到该条记录');window.location.href='../autocli'</script>")
        return response
    content = {
        'data': data,
        'bg_autocli': bg,
        'dropdown_tb': dropdown,
        'user': query_username,
        'uid': query_uid,
        'name': query_nickname,
        'images': images
    }
    return render(req, '../templates/moban1788/tools/detail_client.html', content,
                  )


# 统计禅道bug
def statistics(req):
    # 判断是手机访问还是浏览器访问
    # ua = req.META['HTTP_USER_AGENT']
    # if "Mobile" not in ua:
    #     response = HttpResponse()
    #     response.write(str.format("<script language=javascript>window.location.href='../error';</script>"))
    #     return response
    version = req.GET.get('version', '3')
    # selected = req.GET.get('build', '')
    score = 100
    # if version == '':
    #     version = '3'
    # selected = 'trunk'
    res_show = blued_show(version)
    # score = 70  # 版本发版得分
    dicBild = []
    result = chandao_pie(version, res_show[0][0])
    # print res_show[0][0]
    if result == 0:
        response = HttpResponse()
        response.write("<script>alert('未找到,请重新选择');window.location.href='../statistics'</script>")
        return response
    else:
        build = result[0]
        pie = result[1]
        other = int(pie[0][0][0]) - int(pie[1][0][0]) - int(pie[2][0][0]) - int(pie[3][0][0]) - int(pie[4][0][0])
        for bil in build:
            dicBild.append(bil[0])
        # 获取折线图数据,Bug收敛曲线
        line = result[2]
        localtime = result[3]
        myfifst = []
        mysecond = []
        mythird = []
        for myf in res_show[3][::-1]:
            myfifst.append(myf[0])
            mysecond.append(myf[1])
            mythird.append(myf[2])
        # 总分100分,低分20分
        #  当期残留设置20分
        if res_show[1][0] in range(0, 5):
            score = score
        elif res_show[1][0] in range(5, 10):
            score = score - 5
        elif res_show[1][0] in range(10, 15):
            score = score - 10
        else:
            score = score - 15
        bug_show = res_show[3][0][2]

        #  BUG收敛曲线设置40分
        if bug_show in range(0, 5):
            score = score
        elif bug_show in range(5, 10):
            score = score - 5
        elif bug_show in range(10, 15):
            score = score - 10
        elif bug_show in range(15, 20):
            score = score - 15
        elif bug_show in range(20, 25):
            score = score - 20
        elif bug_show in range(25, 30):
            score = score - 25
        elif bug_show in range(30, 35):
            score = score - 30
        else:
            score = score - 35

        # 需求变更设置20分
        req_result = res_show[4][1]
        if req_result in range(0, 5):
            score = score
        elif req_result in range(5, 10):
            score = score - 5
        elif req_result in range(10, 15):
            score = score - 10
        elif req_result in range(15, 20):
            score = score - 15
        else:
            score = score - 20

    content = {
        'lfirst': res_show[0][0],
        'lsencond': res_show[0][1],
        'lthred': res_show[0][2],
        'nowData': res_show[1][::-1],
        'hisData': res_show[2],
        'myfirst': myfifst,
        'mysecond': mysecond,
        'mythird': mythird,
        'score': score,
        'req': res_show[4][::-1],
        'myversion': version,
        # 'myselected':selected,
        'build': dicBild,
        'fixed': pie[1][0][0],
        'noresolve': pie[2][0][0],
        'bydesign': pie[3][0][0],
        'notrepro': pie[4][0][0],
        'other': other,
        'localtime': json.dumps(localtime),
        'date0': localtime[0],
        'submit0': line[0][0][0][0],
        'fixed0': line[0][1][0][0],
        'bydesign0': line[0][2][0][0],
        'notrepro0': line[0][3][0][0],
        'date1': localtime[1],
        'submit1': line[1][0][0][0],
        'fixed1': line[1][1][0][0],
        'bydesign1': line[1][2][0][0],
        'notrepro1': line[1][3][0][0],
        'date2': localtime[2],
        'submit2': line[2][0][0][0],
        'fixed2': line[2][1][0][0],
        'bydesign2': line[2][2][0][0],
        'notrepro2': line[2][3][0][0],
        'date3': localtime[3],
        'submit3': line[3][0][0][0],
        'fixed3': line[3][1][0][0],
        'bydesign3': line[3][2][0][0],
        'notrepro3': line[3][3][0][0],
        'date4': localtime[4],
        'submit4': line[4][0][0][0],
        'fixed4': line[4][1][0][0],
        'bydesign4': line[4][2][0][0],
        'notrepro4': line[4][3][0][0],
    }
    return render(req, '../templates/outweb/statistic.html', content)


def test_h5(req):
    return render(req, '../templates/outweb/test_h5.html')


def errorpage(req):
    return render(req, '../templates/outweb/error.html')


def dingding(req):
    time_now = time.strftime("%H:%M:%S", time.localtime())
    mytime = "当前时间:  %s" % str(time_now)
    if int(time_now[0:2]) <= 12:
        ltext = "新的一天开始，你打卡了吗？"
        attent = "哇塞,好棒啊,你这么棒还不赶快去工作~~"
    else:
        ltext = "工作结束，不要忘记打卡哟！"
        attent = "累了一天了,赶紧回家再工作吧,哇哈哈~~"

    content = {
        'mytime': mytime,
        'ltext': ltext,
        'attent': attent
    }
    return render(req, '../templates/outweb/dingding.html', content)


def remain_bug(req):
    version = req.GET.get('version', '')
    selected = req.GET.get('build', '')
    # selected = 'trunk'
    dicBild = []
    if version == '' and selected == '':
        version = '3'
        selected = 'trunk'
    result = chandao_pie(version, selected)
    if result == 0:
        response = HttpResponse()
        response.write("<script>alert('未找到,请重新选择');window.location.href='../bug'</script>")
        return response
    else:
        build = result[0]
        pie = result[1]
        other = int(pie[0][0][0]) - int(pie[1][0][0]) - int(pie[2][0][0]) - int(pie[3][0][0]) - int(pie[4][0][0])
        for bil in build:
            dicBild.append(bil[0])
        # 获取折线图数据,Bug收敛曲线
        line = result[2]
        localtime = result[3]
    content = {
        'myversion': version,
        'myselected': selected,
        'build': dicBild,
        'fixed': pie[1][0][0],
        'noresolve': pie[2][0][0],
        'bydesign': pie[3][0][0],
        'notrepro': pie[4][0][0],
        'other': other,
        'localtime': json.dumps(localtime),
        'date0': localtime[0],
        'submit0': line[0][0][0][0],
        'fixed0': line[0][1][0][0],
        'bydesign0': line[0][2][0][0],
        'notrepro0': line[0][3][0][0],
        'date1': localtime[1],
        'submit1': line[1][0][0][0],
        'fixed1': line[1][1][0][0],
        'bydesign1': line[1][2][0][0],
        'notrepro1': line[1][3][0][0],
        'date2': localtime[2],
        'submit2': line[2][0][0][0],
        'fixed2': line[2][1][0][0],
        'bydesign2': line[2][2][0][0],
        'notrepro2': line[2][3][0][0],
        'date3': localtime[3],
        'submit3': line[3][0][0][0],
        'fixed3': line[3][1][0][0],
        'bydesign3': line[3][2][0][0],
        'notrepro3': line[3][3][0][0],
        'date4': localtime[4],
        'submit4': line[4][0][0][0],
        'fixed4': line[4][1][0][0],
        'bydesign4': line[4][2][0][0],
        'notrepro4': line[4][3][0][0],
    }
    return render(req, '../templates/outweb/statistics.html', content)


def loader(req):
    is_online = req.GET.get('is_online', 1)
    is_get = req.GET.get('is_get', '')
    data_post = req.GET.get('data_post', '')
    gest_uid = req.GET.get('gest_uid', '')
    num = req.GET.get('num', 0)
    url = req.GET.get('url', '')
    all_num = req.GET.get('all_num', '')
    connect_num = req.GET.get('connect_num', '')
    uid = req.GET.get('uid', '')
    if all_num != '' and connect_num != '' and uid != '':
        result = client.main(int(all_num), int(connect_num), int(uid))
        if result == 'success':
            response = HttpResponse()
            response.write("<script>alert('运行成功');window.location.href='../loader'</script>")
            return response
        else:
            response = HttpResponse()
            response.write("<script>alert('运行失败');window.location.href='../loader'</script>")
            return response
    # print is_online, is_get, data_post, num, url
    if is_online == '1':
        url_ym = 'https://argo.blued.cn'
    else:
        url_ym = 'http://106.75.100.161'
    myurl = [url]
    count_online = load.objects.filter(type=1).count()
    count_test = load.objects.filter(type=0).count()
    result = ''
    if url != '':
        online_data = load.objects.filter(type=int(is_online))
        count = online_data.count()
        try:
            num = int(num)
        except:
            response = HttpResponse()
            response.write("<script>alert('数量必须是数字,请输入数字');window.location.href='../loader'</script>")
            return response
        if num > count:
            response = HttpResponse()
            response.write("<script>alert('数量不能多于总数');window.location.href='../loader'</script>")
            return response
        my_data = online_data[0:num].values()
        # for data in online_data[0:num].values():
        #     zidian[data['username']] = data['password']
        #     uid.append(data['uid'])
        # mydic.append(zidian)
        if is_get == '0':
            data_post = ''
        else:
            if data_post == '':
                data_post = {}
            else:
                try:
                    data_post = eval(data_post)
                    if type(data_post) != dict:
                        response = HttpResponse()
                        response.write("<script>alert('POST数据格式不正确,需要传字典');window.location.href='../loader'</script>")
                        return response
                except:
                    response = HttpResponse()
                    response.write("<script>alert('POST数据格式不正确,需要传字典');window.location.href='../loader'</script>")
                    return response
        result = myloader(my_data, myurl, data_post, url_ym, gest_uid)
        atc = loader_history()
        atc.url = url
        atc.number = int(num)
        atc.is_online = int(is_online)
        atc.is_post = int(is_get)
        atc.time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
        # atc.time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        atc.save()
    history = loader_history.objects.all()
    # 分页
    paginator = Paginator(history, ONE_PAGE_OF_DATA)
    try:
        page = int(req.GET.get('page', 1))
        if page < 1:
            page = 1
    except ValueError:
        page = 1
    try:
        history_list = paginator.page(page)
    except(EmptyPage, InvalidPage, PageNotAnInteger):
        history_list = paginator.page(page.num_pages)
    content = {
        'result': result,
        'count_online': count_online,
        'count_test': count_test,
        'bg_loader': bg,
        'dropdown_tt': dropdown,
        'history_list': history_list,
        'history': history,
    }
    return render(req, '../templates/moban1788/tools/loader.html', content,
                  )


def show(req):
    home_a = interface_show.objects.filter(device='Android', source='home')
    home_i = interface_show.objects.filter(device='Ios', source='home')
    inter_a = interface_show.objects.filter(device='Android', source='inter')
    inter_i = interface_show.objects.filter(device='Ios', source='inter')
    value_ha = home_a.values()
    value_hi = home_i.values()
    value_ia = inter_a.values()
    value_ii = inter_i.values()
    lenth_ha = []
    lenth_hi = []
    lenth_ia = []
    lenth_ii = []
    version_ha = []
    version_hi = []
    version_ia = []
    version_ii = []
    for data_ha in value_ha:
        lenth_ha.append(round((float(data_ha['lenth']) / (1024 * 1024)), 2))
        version_ha.append(int(data_ha['version']))
    for data_hi in value_hi:
        lenth_hi.append(round((float(data_hi['lenth']) / (1024 * 1024)), 2))
        version_hi.append(int(data_hi['version']))
    for data_ia in value_ia:
        lenth_ia.append(round((float(data_ia['lenth']) / (1024 * 1024)), 2))
        version_ia.append(int(data_ia['version']))
    for data_ii in value_ii:
        lenth_ii.append(round((float(data_ii['lenth']) / (1024 * 1024)), 2))
        version_ii.append(int(data_ii['version']))
    content = {
        'lenth_ha': lenth_ha,
        'version_ha': version_ha,
        'lenth_hi': lenth_hi,
        'version_hi': version_hi,
        'lenth_ia': lenth_ia,
        'version_ia': version_ia,
        'lenth_ii': lenth_ii,
        'version_ii': version_ii,
    }
    return render(req, '../templates/outweb/show.html', content)


def training(req):
    if 'Chrome' not in req.META['HTTP_USER_AGENT']:
        response = HttpResponse()
        response.write("<script>alert('请使用Chrome浏览器下载PPT,给您带来不便,敬请谅解'); window.location.href='../index'</script>")
        return response
    import platform
    if platform.platform().split('-')[0] == 'Darwin':
        path = '%s/qa/static/ppt' % str(sys.path[0])
    else:
        path = '/home/work/jiaoshupeng/qaweb/qa/static/ppt'
    file = os.walk(path)
    aloneFile = {}
    allFile = []
    i = 0
    for path, d, filelist in file:
        for filename in filelist:
            aloneFile = aloneFile.copy()
            filetime = os.stat(path + '/' + filename.encode('utf-8')).st_ctime
            # 转换成localtime
            time_local = time.localtime(filetime)
            # 转换成新的时间格式(2016-05-05 20:28:54)
            dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local)
            splitFile = filename.split('-')
            aloneFile['filename'] = filename
            aloneFile['quarter'] = splitFile[0]
            aloneFile['module'] = splitFile[1]
            aloneFile['name'] = splitFile[2][:-5]
            aloneFile['date'] = dt
            aloneFile['filetime'] = filetime
            allFile.append(aloneFile)
    import operator
    content = {
        'allFile': sorted(allFile, key=operator.itemgetter('filetime'))
    }
    return render(req, '../templates/moban1788/tools/training.html', content,
                  )


def packet_channel(req):
    if 'Chrome' not in req.META['HTTP_USER_AGENT']:
        response = HttpResponse()
        response.write("<script>alert('请使用Chrome浏览器下载PPT,给您带来不便,敬请谅解'); window.location.href='../index'</script>")
        return response
    import platform
    if platform.platform().split('-')[0] == 'Darwin':
        path = '%s/qa/static/packet' % str(sys.path[0])
    else:
        path = '/home/work/jiaoshupeng/qaweb/qa/static/packet'
    file = os.walk(path)
    aloneFile = {}
    allFile = []
    i = 0
    for path, d, filelist in file:
        for filename in filelist:
            # filename = 'blued_5.3.1_a66880_release_test_inhome.apk'
            aloneFile = aloneFile.copy()
            filetime = os.stat(path + '/' + filename.encode('utf-8')).st_ctime
            # 转换成localtime
            time_local = time.localtime(filetime)
            # 转换成新的时间格式(2016-05-05 20:28:54)
            dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local)
            splitFile = filename.split('_')
            aloneFile['filename'] = filename
            last = filename[-3:]
            if last in ['apk', 'ipa']:
                if last == 'apk':
                    aloneFile['quarter'] = 'Android'
                else:
                    aloneFile['quarter'] = 'Ios'
                channel = splitFile[1].replace('.', '')
                print channel
                aloneFile['module'] = splitFile[1]
                aloneFile['name'] = splitFile[2][:-5]
                aloneFile['date'] = dt
                aloneFile['filetime'] = filetime
                aloneFile['channel'] = int(channel)
                allFile.append(aloneFile)
    import operator
    content = {
        'allFile': sorted(allFile, key=operator.itemgetter('channel'))[::-1]
    }
    return render(req, '../templates/moban1788/tools/packet.html', content,
                  )


def searchmv(req):
    name = req.GET.get('name', '')
    if name != '':
        list_object = []
        mv = search_movice(name)
        for i in range(len(mv)):
            list = {}
            list['id'] = i
            list['url'] = mv[i]
            list_object.append(list)
    username = req.session.get('username')
    if username == None:
        username1 = '登录'
    else:
        username1 = username
    return render(req, '../templates/moban1788/tools/mv.html', locals())


def onairlist(req):
    page = req.GET.get('page', 1)
    from zhuri import select_lid, getdata, del_lid, insert_lid
    num = int(page)
    url = "https://argo.blued.cn/live/onairlist?page=%d" % num
    data_list_a = getdata('2574006368@qq.com', '123456', url)
    data_list_b = getdata('977138190@qq.com', '123456', url)
    data_a = json.loads(data_list_a, object_pairs_hook=OrderedDict)['data']
    data_b = json.loads(data_list_b, object_pairs_hook=OrderedDict)['data']
    temp_a = []
    temp_b = []
    if num == 1:
        del_lid()
    list_lid_a = select_lid('a')
    list_lid_b = select_lid('b')
    for user in data_a:
        uid = user['uid']
        lid = user['lid']
        if lid not in list_lid_a or list_lid_a == []:
            insert_lid(uid, lid, 'a')
            temp_a.append(user)
    for user in data_b:
        uid = user['uid']
        lid = user['lid']
        if lid not in list_lid_b or list_lid_b == []:
            insert_lid(uid, lid, 'b')
            temp_b.append(user)
    if num != 1 and len(temp_a) < 4 and len(temp_b) < 4:
        response = HttpResponse()
        response.write("<script>alert('非法操作,返回到首页');window.location.href='../onairlist'</script>")
        return response
    return render(req, '../templates/moban1788/tools/onairlist.html', locals(),
                  )


def autoLog(req):
    page = req.GET.get('page', '')
    # http://127.0.0.1:8000/qa/autolog/?page=Test2017-07-27-16-09.html
    return render(req, '../templates/automation/%s' % page, locals(),
                  )


def inf_log(req):
    session_id = req.GET.get('session_id', '')
    if session_id == '':
        response = HttpResponse()
        response.write("<script>alert('请求id为空');window.location.href='../'</script>")
        return response
    try:
        data = interface_inf_log.objects.filter(session_id=session_id)
        data = data.values()[0]

        def jsons(data):
            data = data.replace(',', ', \n').replace("u'", "'") \
                .replace("{'", "{\n '").replace('}', '\n}').replace("{\"", "{\n\"")
            return data

        header = jsons(str(data['header']))
        diff = jsons(str(data['diff']))
        try:
            response = jsons(str(data['response'].decode('unicode_escape')))
        except:
            response = jsons(str(data['response']))
        if data['method'] == 'post':
            post = jsons(str(data['body'].decode('unicode_escape')))
    except:
        response = HttpResponse()
        response.write("<script>alert('未找到该条记录');window.location.href='../'</script>")
        return response
    return render(req, '../templates/moban1788/autolog/moble_interface.html', locals())

# # 性能测试启动数据_国内
# def startup(req):
#     active_startup = "active"
#     data_android = interface_startup.objects.filter(device=0, app=1)
#     data_ios = interface_startup.objects.filter(device=1, app=1)
#     if len(data_android.values()) == 0:
#         data_android = ""
#     if len(data_ios.values()) == 0:
#         data_ios = ""
#     return render(req, '../templates/moban1788/../templates/performance/startup.html', locals())
#
#
# # 性能测试启动数据_国际
# def startup_inter(req):
#     active_startup_inter = "active"
#     data_android = interface_startup.objects.filter(device=0, app=2)
#     data_ios = interface_startup.objects.filter(device=1, app=2)
#     if len(data_android.values()) == 0:
#         data_android = ""
#     if len(data_ios.values()) == 0:
#         data_ios = ""
#     return render(req, '../templates/moban1788/../templates/performance/startup_inter.html', locals())
